home *** CD-ROM | disk | FTP | other *** search
- Path: castle.nando.net!news
- From: actuary@nando.net (Bill McCarthy)
- Newsgroups: comp.lang.c
- Subject: Re: qsort help
- Date: 4 Jan 1996 03:32:52 GMT
- Organization: News & Observer Public Access
- Message-ID: <4cfhp4$pd@castle.nando.net>
- References: <4ccio7$7c0@charm.magnus.acs.ohio-state.edu>
- Reply-To: actuary@nando.net (Bill McCarthy)
- NNTP-Posting-Host: grail2007.nando.net
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <4ccio7$7c0@charm.magnus.acs.ohio-state.edu>, xiaoyi@bmecg.bme.ohio-state.edu (Xiaoyi Wu) writes:
- >Hi, I am having some problems with the qsort routine.
- >
- >
- >int (*compar)(int *a, int *b)
- >{
- > if (*a < *b) return -1;
- > else if (*a == *b) return 0;
- > else return 1;
- >}
-
- The compare function for qsort takes two pointers to const void.
-
- So,
-
- int compar( const void *x, const void *y )
- {
- const int *a = x;
- const int *b = y;
-
- /* you function body goes here */
- }
-
- Bill McCarthy
- actuary@nando.net
- Wendell, NC USA
-
-